package org.dick.demo.handler;

import com.core.annotation.Command;
import com.core.exception.BizException;
import com.core.handler.ExecuteCommandHandler;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.Component;

import java.util.Map;

@Slf4j
@Command("user.create")
@Component(value = "UserCreateCmd")
public class UserCreateCmd extends ExecuteCommandHandler<String> {

    @Override
    protected Map<String, Object> beforeExecute(Map<String, Object> params) {
        if (!params.containsKey("username") || params.get("username").toString().isEmpty()) {
            throw new BizException("用户名不能为空");
        }
        return params;
    }
    @Override
    protected String doExecute(Map<String, Object> params) {
        return "用户已创建: " + params.get("username");
    }

}
